//- Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. 
//- <https://www.chatopera.com>, Licensed under the Chunsong Public 
//- License, Version 1.0  (the "License"), https://docs.cskefu.com/licenses/v1.html
//- Unless required by applicable law or agreed to in writing, software
//- distributed under the License is distributed on an "AS IS" BASIS,
//- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//- See the License for the specific language governing permissions and
//- limitations under the License.
//- Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>
//- Licensed under the Apache License, Version 2.0
//- http://www.apache.org/licenses/LICENSE-2.0
if chatmessage.expmsg && chatmessage.expmsg.contains("hyperlink\":\"http")
    - var expmsg = pugHelper.parseStringToJsonArray(chatmessage.expmsg)[0];
    | 图文消息：#{expmsg.title}
    br
    = expmsg.summary
    br
    a(href="#{expmsg.hyperlink}", target="_blank")
        img.ukefu-media-image(src=chatmessage.message ? chatmessage.message : '', id=chatmessage.id)
else if chatmessage.msgtype && chatmessage.msgtype == "image"
    a(href="/agent/message/image.html?id=" + chatmessage.id, data-toggle="ajax", data-width="950", data-height="600", title="图片")
        img.ukefu-media-image(src=chatmessage.message ? chatmessage.message : '', id=chatmessage.id)
else if chatmessage.msgtype && chatmessage.msgtype == "cooperation"
    a(href="/agent/message/image.html?t=review&id=" + chatmessage.message, data-toggle="ajax", data-width="950", data-height="600", title="图片")
        | 系统发送了一个协作邀请
else if chatmessage.msgtype && chatmessage.msgtype == "file"
    .ukefu-message-file
        .ukefu-file-icon
            i.kfont 
        .ukefu-file-desc
            a(href=chatmessage.message, target="_blank")
                div= chatmessage.filename
                div #{chatmessage.filesize / 1024}kb
else if chatmessage.msgtype && chatmessage.msgtype == "location"
    div #{chatmessage.message}
    if systemConfig && systemConfig.mapkey && systemConfig.mapkey != ''
        .ukefu-map(id="map_" + chatmessage.id)
        script(type="text/javascript").
            var map = new BMap.Map("map_#{chatmessage.id}");
            // 创建地图实例
            var chatmessage_locy = '#{chatmessage.locy}'
            var ggPoint = new BMap.Point(chatmessage_locy ? chatmessage_locy : '0', chatmessage_locy ? chatmessage_locy : '0');  // 创建点坐标
            MapUtil.convert(map, ggPoint, "#{chatmessage.message}", "#{chatmessage.scale ? chatmessage.scale : '15'}");
else if chatmessage.msgtype && chatmessage.msgtype == "voice"
    p.weixinAudio(id="voice_media_" + chatmessage.id, style="width:" + chatmessage.duration && chatmessage.duration != '' ? chatmessage.duration > 30 ? '300px' : 50 + (chatmessage.duration * 10) + 'px' : '50px')
        audio#media(src=chatmessage.message, width="1", height="1", preload="")
        span#audio_area.db.audio_area(title=chatmessage.expmsg)
            span.audio_wrp.db
                span.audio_play_area
                    i.icon_audio_default
                    i.icon_audio_playing
                span.audio_length.tips_global
                    | #{chatmessage.duration}秒
                span#audio_progress.progress_bar(style="width: 0%;")
    if chatmessage.expmsg
        .ukefu-asr
            | #{chatmessage.expmsg}
        script(type="text/javascript").
            $('#voice_media_' + '#{chatmessage.id}').weixinAudio({
                autoplay: false
            });
else
    | !{chatmessage.message}
    if chatmessage.suggestmsg && chatmessage.suggestmsg != ""
        ul.agent-info-list
            for item in chatmessage.suggest
                li.ukefu-suggest-item
                    a.suggestitem(href="javascript:void(0)")
                        | #{item.title}







